package initializers

import (
	"geek-cloud-native/chapter04-0925/global"
	"geek-cloud-native/chapter04-0925/pkg/setting"
	"strings"
)

// SetupConfigs 初始化配置
func SetupConfigs() error {
	newSetting, err := setting.NewSetting(strings.Split(global.Config, ",")...)
	if err != nil {
		return err
	}
	err = newSetting.ReadSection("Server", &global.ServerSetting)
	if err != nil {
		return err
	}
	err = newSetting.ReadSection("Logger", &global.LoggerSetting)
	if err != nil {
		return err
	}
	return nil
}
